package com.qfhd.soft.cjzcore.User;

import android.text.TextUtils;

import com.qfhd.soft.cjzcore.CJZConstant;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;

public class CJZUserHelper {

    public static JSONArray getRequest_sigle(String request){
        JSONArray jsonArray = new JSONArray();
        jsonArray.put(request);
        return jsonArray;
    }

    public static JSONArray getRequest_mutil(ArrayList request){
        ArrayList<String> arrayList = new ArrayList<String>();
        arrayList.addAll(request);
        JSONArray tmp = new JSONArray(arrayList);
        return tmp;
    }


    /**
     * @return 默认传 token，APPKEY
     */
    public static String getParamas_default(){
        JSONObject obj = new JSONObject();
        try {
            obj.put("appkey", CJZConstant.APPKEY);

            if(TextUtils.isEmpty(CJZUser.getInstance().getToken())){

            }
            else{
                obj.put("token",CJZUser.getInstance().getToken());
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return obj.toString();
    }

    public static JSONObject getParamasJSONObject_default(){
        JSONObject obj = new JSONObject();
        try {
            obj.put("appkey", CJZConstant.APPKEY);

            if(TextUtils.isEmpty(CJZUser.getInstance().getToken())){

            }
            else{
                obj.put("token",CJZUser.getInstance().getToken());
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return obj;
    }

    public static String getParamas(String jsonStr){
        JSONObject obj = new JSONObject();
        try {
            obj = new JSONObject(jsonStr);
            obj.put("appkey", CJZConstant.APPKEY);
            if(TextUtils.isEmpty(CJZUser.getInstance().getToken())){

            }
            else{
                obj.put("token",CJZUser.getInstance().getToken());
            }

        }catch (Exception e){
            e.printStackTrace();
        }

        return obj.toString();
    }


}
